#include <stdio.h>

int
main(int argc, char *argv[])
{
  char *file_name="huawei.dat";
  unsigned long times=0xa0000000;
  if (argc>3) {
    printf("Usage: %s [data_file times]", argv[0]);
    exit(1);
  }
  if (argc==3) {
    file_name=argv[1];
    times=atol(argv[2]);
  }

  FILE *fp;
  if ((fp=fopen(file_name, "wb"))==NULL) {
    printf("cannot open file!\n");
    exit(1);
  }

  char buf[]={
    0x0, 0x0, 0x0, 0x0,			// sn1
    0x0, 0x0, 0x0, 0x0,			// sn2
    0x1,				// model type
    0x1,				// bill type
    0xd7, 0x7, 0x0c, 0x1a, 0x1, 0x10, 0x0,	// time:2007/12/26 01:16:00
    0x24, 0xa, 0x13, 0x54, 0x96, 0x48, 0x40, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff  // 13549648403
  };
  long i;
  const short SIZE=sizeof(buf);
  for (i=0xffffffff; i>0xffffffff-times; i--) {
    buf[0]=i&0xff; buf[1]=(i&0xff00)>>8; buf[2]=(i&0xff0000)>>16; buf[3]=(i&0xff000000)>>24;
    buf[4]=i&0xff; buf[5]=(i&0xff00)>>8; buf[6]=(i&0xff0000)>>16; buf[7]=(i&0xff000000)>>24;
    fwrite(buf, SIZE, 1, fp);
  }

  char junk[]={
    times&0xff, times&0xff00, times&0xff0000, times&0xff000000,
    times&0xff, times&0xff00, times&0xff0000, times&0xff000000,
    0xff, 0xff
  };
  fwrite(junk, sizeof(junk), 1, fp);
  
  if (fclose(fp))
    printf("file close error!\n");
  
  return 0;
}
